package com.siyue.controller;

import com.alibaba.fastjson.JSONObject;
import com.siyue.config.RedisLock;
import com.siyue.mq.constants.RabbitMqConstant;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
public class RabbitMqController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/add-msg")
    public String test1() {
        String msg="{\"msgType\":\"STRATEGY\",\"msgData\":{\"szDevId\":\"44010100001326399763_1\",\"alarmType\":\"1\",\"groupName\":\"测试分组\",\"szMainId\":\"44010100001326399763_1\",\"imageUrl\":\"/vplat/vplat_1699256188429_2023-11-06_464.jpg\",\"alarmTime\":\"2023-11-06 15:36:28\",\"confidence\":\"100\",\"strategyId\":\"1699238981584\",\"devName\":\"热成像6.63普通画面\",\"objList\":[{\"confidence\":\"1\",\"objUrl\":\"\"}]}}";
//        JSONObject obj=JSONObject.parseObject(msg);
        String msgId= UUID.randomUUID().toString();
        //发送信息
        rabbitTemplate.convertAndSend(RabbitMqConstant.MSG_EXCHANGE_NAME,
                RabbitMqConstant.MSG_ROUTING_KRY_NAME,msg,new CorrelationData(msgId));
        System.out.println("我已经执行了");
        return "ok";
    }


}
